home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / What's New? / Development Kits / Multiprocessing SDK / Multiprocessing / Multiprocessing.h < prev   
Encoding:
C/C++ Source or Header  |  1998-09-25  |  7.7 KB  |  327 lines  |  [TEXT/CWIE]

  1. /*
  2.      File:        Multiprocessing.h
  3.  
  4.      Contains:    Multiprocessing interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1996-1997 by Apple Computer, Inc. and © 1995-1997 DayStar Digital, Inc.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __MULTIPROCESSING__
  19. #define __MULTIPROCESSING__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __CODEFRAGMENTS__
  25. #include <CodeFragments.h>
  26. #endif
  27.  
  28. #include <stdarg.h>
  29.  
  30.  
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42.  
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=power
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50.  
  51. #if TARGET_CPU_PPC
  52. #define MPCopyrightNotice                                \
  53.     "Copyright © 1995, 1996 DayStar Digital, Inc.\n"            \
  54.     "Portions Copyright © 1995 Apple Computer, Inc.\n"
  55. #define MPLibraryName "MPLibrary"
  56. #define MPLibraryCName MPLibraryName
  57. #define MPLibraryPName "\p" MPLibraryName
  58. #define MP_API_Version "1.4"
  59.  
  60. enum {
  61.     MPLibrary_MajorVersion        = 1,
  62.     MPLibrary_MinorVersion        = 4,
  63.     MPLibrary_Release            = 1,
  64.     MPLibrary_DevelopmentRevision = 2
  65. };
  66.  
  67. typedef struct OpaqueMPTaskID*             MPTaskID;
  68. typedef struct OpaqueMPQueueID*         MPQueueID;
  69. typedef struct OpaqueMPSemaphoreID*     MPSemaphoreID;
  70. typedef struct OpaqueMPCriticalRegionID*  MPCriticalRegionID;
  71. typedef UInt32                             MPSemaphoreCount;
  72. typedef UInt32                             MPTaskOptions;
  73. typedef CALLBACK_API_C( OSStatus , TaskProc )(void *parameter);
  74. typedef CALLBACK_API_C( void *, MPRemoteProcedure )(void *parameter);
  75. typedef CALLBACK_API_C( void , MPPrintfHandler )(MPTaskID taskID, const char *format, va_list args);
  76.  
  77. enum {
  78.     kDurationImmediate            = 0L,
  79.     kDurationForever            = 0x7FFFFFFF
  80. };
  81.  
  82.  
  83. enum {
  84.     kMPNoID                        = 0
  85. };
  86.  
  87.  
  88. #define MPLibraryIsLoaded()        \
  89.   ( ( (UInt32)_MPIsFullyInitialized != (UInt32)kUnresolvedCFragSymbolAddress ) \
  90.    && _MPIsFullyInitialized() )
  91.  
  92.  
  93. EXTERN_API_C( UInt32 )
  94. MPProcessors                    (void);
  95.  
  96. EXTERN_API_C( OSStatus )
  97. MPCreateTask                    (TaskProc                 entryPoint,
  98.                                  void *                    parameter,
  99.                                  ByteCount                 stackSize,
  100.                                  MPQueueID                 notifyQueue,
  101.                                  void *                    terminationParameter1,
  102.                                  void *                    terminationParameter2,
  103.                                  MPTaskOptions             options,
  104.                                  MPTaskID *                task);
  105.  
  106.  
  107. EXTERN_API_C( OSStatus )
  108. MPTerminateTask                    (MPTaskID                 task,
  109.                                  OSStatus                 terminationStatus);
  110.  
  111.  
  112. EXTERN_API_C( void )
  113. MPExit                            (OSStatus                 status);
  114.  
  115.  
  116. EXTERN_API_C( MPTaskID )
  117. MPCurrentTaskID                    (void);
  118.  
  119.  
  120. EXTERN_API_C( void )
  121. MPYield                            (void);
  122.  
  123.  
  124. EXTERN_API_C( OSStatus )
  125. MPCreateQueue                    (MPQueueID *            queue);
  126.  
  127.  
  128. EXTERN_API_C( OSStatus )
  129. MPDeleteQueue                    (MPQueueID                 queue);
  130.  
  131.  
  132. EXTERN_API_C( OSStatus )
  133. MPNotifyQueue                    (MPQueueID                 queue,
  134.                                  void *                    param1,
  135.                                  void *                    param2,
  136.                                  void *                    param3);
  137.  
  138.  
  139. EXTERN_API_C( OSStatus )
  140. MPWaitOnQueue                    (MPQueueID                 queue,
  141.                                  void **                param1,
  142.                                  void **                param2,
  143.                                  void **                param3,
  144.                                  Duration                 timeout);
  145.  
  146.  
  147. EXTERN_API_C( OSStatus )
  148. MPCreateSemaphore                (MPSemaphoreCount         maximumValue,
  149.                                  MPSemaphoreCount         initialValue,
  150.                                  MPSemaphoreID *        semaphore);
  151.  
  152.  
  153. #define MPCreateBinarySemaphore(semaphore) \
  154.         MPCreateSemaphore(1, 1, (semaphore))
  155.  
  156. EXTERN_API_C( OSStatus )
  157. MPWaitOnSemaphore                (MPSemaphoreID             semaphore,
  158.                                  Duration                 timeout);
  159.  
  160.  
  161. EXTERN_API_C( OSStatus )
  162. MPSignalSemaphore                (MPSemaphoreID             semaphore);
  163.  
  164.  
  165. EXTERN_API_C( OSStatus )
  166. MPDeleteSemaphore                (MPSemaphoreID             semaphore);
  167.  
  168.  
  169. EXTERN_API_C( OSStatus )
  170. MPCreateCriticalRegion            (MPCriticalRegionID *    criticalRegion);
  171.  
  172.  
  173. EXTERN_API_C( OSStatus )
  174. MPEnterCriticalRegion            (MPCriticalRegionID     criticalRegion,
  175.                                  Duration                 timeout);
  176.  
  177.  
  178. EXTERN_API_C( OSStatus )
  179. MPExitCriticalRegion            (MPCriticalRegionID     criticalRegion);
  180.  
  181.  
  182. EXTERN_API_C( OSStatus )
  183. MPDeleteCriticalRegion            (MPCriticalRegionID     criticalRegion);
  184.  
  185.  
  186. EXTERN_API_C( LogicalAddress )
  187. MPAllocate                        (ByteCount                 size);
  188.  
  189. EXTERN_API_C( void )
  190. MPFree                            (LogicalAddress         object);
  191.  
  192.  
  193. EXTERN_API_C( void )
  194. MPBlockCopy                        (LogicalAddress         sourcePtr,
  195.                                  LogicalAddress         destPtr,
  196.                                  ByteCount                 blockSize);
  197.  
  198.  
  199. /**************************************************************************
  200.  *
  201.  *    MPTaskIsToolboxSafe() and MPRPC() were functions added by DayStar. 
  202.  *    The 1.4 MPLibrary exports the names with an underscore prefix. 
  203.  *    To work around this, #defines have been added to automatically
  204.  *    add the underscore.
  205.  *
  206.  */
  207.  
  208. #define    MPTaskIsToolboxSafe        _MPTaskIsToolboxSafe
  209. #define    MPRPC                    _MPRPC
  210.  
  211. /* 
  212.     MPTaskIsToolboxSafe() allows routines which are otherwise unaware that 
  213.     they are being called from an MP task to check to see if it is permissible
  214.     to make a call to the Macintosh toolbox.  (It is okay to make toolbox 
  215.     calls only if the routine is not being called from an MP task).
  216. */
  217. EXTERN_API_C( Boolean )
  218. MPTaskIsToolboxSafe                (MPTaskID                 task);
  219.  
  220. /*
  221.     MPRPC() calls its MPRemoteProcedure parameter in the application's main 
  222.     thread when the app next calls WaitNextEvent, EventAvail, SystemTask, 
  223.     MPYield, MPWaitOnQueue, MPWaitOnSemaphore, or MPEnterCriticalRegion. The  
  224.     return value of the MPRemoteProcedure is returned as the result of MPRPC.  
  225.     The MPRemoteProcedure function can call any toolbox function except  
  226.     SystemTask (or anything that calls it).
  227. */
  228. EXTERN_API_C( void *)
  229. MPRPC                            (MPRemoteProcedure         theProc,
  230.                                  void *                    parameter);
  231.  
  232.  
  233.  
  234. /**************************************************************************
  235.  *
  236.  *    The following routines were added by DayStar for debugging purposes.
  237.  *    You should not use these in shipping products.  You can tell which
  238.  *    functions are for debugging only because they begin with an underscore
  239.  *
  240.  */
  241. EXTERN_API_C( Boolean )
  242. _MPIsFullyInitialized            (void);
  243.  
  244.  
  245. /*
  246.     MPAllocateSys() does the same thing as MPAllocate() except the memory
  247.     is allocated from the system heap.
  248. */
  249. EXTERN_API_C( LogicalAddress )
  250. _MPAllocateSys                    (ByteCount                 size);
  251.  
  252.  
  253. EXTERN_API_C( Boolean )
  254. _MPLibraryIsCompatible            (const char *            versionCString,
  255.                                  UInt32                 major,
  256.                                  UInt32                 minor,
  257.                                  UInt32                 release,
  258.                                  UInt32                 revision);
  259.  
  260. /*
  261.     MPLibraryVersion() retrieves the hardcoded version information built into
  262.     the currently active Multiprocessing API Library.
  263. */
  264. EXTERN_API_C( void )
  265. _MPLibraryVersion                (const char **            versionCString,
  266.                                  UInt32 *                major,
  267.                                  UInt32 *                minor,
  268.                                  UInt32 *                release,
  269.                                  UInt32 *                revision);
  270.  
  271. EXTERN_API_C( void )
  272. _MPInitializePrintf                (MPPrintfHandler         pfn);
  273.  
  274. EXTERN_API_C( void )
  275. _MPPrintf                        (const char *            format,
  276.                                  ...);
  277.  
  278.  
  279. /*
  280.      MPDebugStr() works just like DebugStr() except that it is safe
  281.     to call it from an MP task.
  282. */
  283. EXTERN_API_C( void )
  284. _MPDebugStr                        (ConstStr255Param         msg);
  285.  
  286. /*
  287.  
  288.     MPStatusPString() and MPStatusCString() provide a way to translate an OSStatus
  289.     value returned from one of the MP API calls into either a Pascal string or a
  290.     C string.  Thus, if an MPLibrary function returns an error then the application
  291.     (not a task) could use the following:
  292.  
  293.     status = MPxxx( function_params );
  294.     DebugStr( MPStatusPString( status ) );
  295.     
  296. */
  297. EXTERN_API_C( StringPtr )
  298. _MPStatusPString                (OSStatus                 status);
  299.  
  300. EXTERN_API_C( const char *)
  301. _MPStatusCString                (OSStatus                 status);
  302.  
  303.  
  304. #endif  /* TARGET_CPU_PPC */
  305.  
  306.  
  307. #if PRAGMA_STRUCT_ALIGN
  308.     #pragma options align=reset
  309. #elif PRAGMA_STRUCT_PACKPUSH
  310.     #pragma pack(pop)
  311. #elif PRAGMA_STRUCT_PACK
  312.     #pragma pack()
  313. #endif
  314.  
  315. #ifdef PRAGMA_IMPORT_OFF
  316. #pragma import off
  317. #elif PRAGMA_IMPORT
  318. #pragma import reset
  319. #endif
  320.  
  321. #ifdef __cplusplus
  322. }
  323. #endif
  324.  
  325. #endif /* __MULTIPROCESSING__ */
  326.  
  327.